<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String basePath = request.getScheme() +
            "://"
            + request.getServerName() + ":"
            + request.getServerPort()
            + request.getContextPath() + "/";
    int index=1;
%>
<!DOCTYPE html>
<html>
<head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <script type="text/javascript" src="jquery/jquery-2.1.1.min.js"></script>
    <script type="text/javascript">
        $(function (){
            $("#submitBtn").click(function (){
                var data=$("#answers").serialize();
                data+="&eid=${examination.eid}";
                data+="&stuId=${user.stuId}"
                $.ajax({
                   url:"workbench/student/practice/markTest.do",
                    data:data,
                    type:"post",
                    dataType:"json",
                    success:function (data){
                        alert("得分为："+data.score);
                        window.location.href="toView/workbench/student/practice/unFinished";
                    }
                })
            })

            $("#returnBtn").click(function (){
                window.location.href="toView/workbench/student/practice/unFinished";
            })
        })
    </script>
</head>
<body>
<h2>${examination.eName}</h2>
   <hr>
   <br><br>
<table style="position: relative;left: 350px" id="content">
    <tr>
        <td>名称</td>
        <td>${examination.eName}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
        <td>成绩类型</td>
        <td>百分制&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
        <td>开始日期</td>
        <td>${examination.startTime}</td>
    </tr>
    <tr>
        <td>题目数</td>
        <td>${examination.eName}</td>
        <td>总分数</td>
        <td>${10*examination.count}</td>
        <td>结束日期</td>
        <td>${examination.endTime}</td>
    </tr>
</table>
   <form id="answers" action="" method="post">
       <c:forEach items="${questionList}" var="n" >
           <br> <br>
           <hr>
           <div id="${n.qid}" style="position: relative;left: 350px">
               <div style="position: relative;top: 15px;">
                   <span id="q${n.qid}"><%=index++%>.  </span>
                   <span>${n.head}  </span>
                   <span> (    )  (10分）</span>
               </div>
               <br>
               <div style="position: relative;top: 10px;">
                   <span><input type="radio" name="answer_${n.qid}" value="A" style="width:15px;height: 15px;"></span>
                   <span>A.     </span>
                   <span>${n.answerA}</span>
               </div>
               <br>
               <div style="position: relative;top: 10px;">
                   <span><input type="radio" name="answer_${n.qid}" value="B" style="width:15px;height: 15px;"></span>
                   <span>B.     </span>
                   <span>${n.answerB}</span>
               </div>
               <br>
               <div style="position: relative;top: 10px;">
                   <span><input type="radio" name="answer_${n.qid}" value="C" style="width:15px;height: 15px;"></span>
                   <span>C.     </span>
                   <span>${n.answerC}</span>
               </div>
               <br>
               <div style="position: relative;top: 10px;">
                   <span><input type="radio" name="answer_${n.qid}" value="D" style="width:15px;height: 15px;"></span>
                   <span>D.     </span>
                   <span>${n.answerD}</span>
               </div>
           </div>
       </c:forEach>
   </form>
<br><br>
   <button style="position: relative;left: 600px;width: 60px;height: 40px" id="returnBtn">返回</button>
   <button style="position: relative;left: 600px;width: 60px;height: 40px" id="submitBtn">交卷</button>

</body>
</html>